package com.yc.yyds.servlet;

import com.yc.yyds.Bean.Result;
import com.yc.yyds.biz.BizException;
import com.yc.yyds.biz.CommentBiz;
import com.yc.yyds.util.ToJsonUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "CommentSaveServlet", value = "/CommentSaveServlet.s")
public class CommentSaveServlet extends HttpServlet {
    CommentBiz biz= new CommentBiz();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userid=  request.getParameter("userid");
        String movieid = request.getParameter("movieid");
        String content = request.getParameter("content");
        Result result;
        try {
            biz.saveComment(userid,movieid,content,"0","0");
            result =new Result(1,"成功发布评论",null);
            ToJsonUtil.toJson(response,result);
        } catch (BizException e) {
            e.printStackTrace();
            result =new Result(0,e.getMessage(),null);
            ToJsonUtil.toJson(response,result);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
